<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>우리상인로그인</title>
<link href="/Jangdolbaeng2/css/bootstrap.min.css" rel="stylesheet">
<link href="/Jangdolbaeng2/css/customer/common.css" rel="stylesheet">
<script src="/Jangdolbaeng2/js/jquery-1.11.1.js"></script>
<script src="/Jangdolbaeng2/js/bootstrap.min.js"></script>
<script type="text/javascript">
//Login버튼에 클릭 이벤트 지정
$(document).ready(function() {
	$('#seller_login').on('click', sellerForm).css('cursor', 'pointer');
	$('#admin_login').on('click', adminForm).css('cursor', 'pointer');
});


//Login버튼 누르면 실행
function sellerForm(){
	//사용자가 입력한 ID와 비밀번호 읽기, 빈칸이면 경고.
	//서버로 ID와 비번 전송
	
	var id = $('#seller_id').val();
	var password = $('#seller_password').val();
	
	if (id.length == 0) {
		alert('아이디를 입력해주세요.');
		id.focus
		return;		
	}
	
	if (password.length == 0) {
		alert('비밀번호를 입력해주세요.');
		id.focus
		return;		
	}
	
	$.ajax({
		url: 'login.action',
		type: 'POST',
		dateType: 'json',
		data: {
			seller_id: id,
			password: password
		},
		success: sellerLogin	
	});
	
}//sellerForm()

function adminForm(){
	//사용자가 입력한 ID와 비밀번호 읽기, 빈칸이면 경고.
	//서버로 ID와 비번 전송
	
	var id = $('#admin_id').val();
	var password = $('#admin_password').val();
	
	if (id.length == 0) {
		alert('아이디를 입력해주세요.');
		id.focus
		return;		
	}
	
	if (password.length == 0) {
		alert('비밀번호를 입력해주세요.');
		id.focus
		return;		
	}
	
	$.ajax({
		url: 'login.action',
		type: 'POST',
		dateType: 'json',
		data: {
			seller_id: id,
			password: password
		},
		success: adminLogin	
	});
	
}//adminForm()


//로그인 처리 후 실행
function sellerLogin(json) {
	var loginCheck = json.loginCheck;
	
	if(loginCheck == true) {
		alert('로그인 되었습니다.');
		location.href="/Jangdolbaeng2/seller/productManager.action";		
	}
	else {
		alert('올바른 아이디와 비밀번호를 입력해주세요.');
	}
	
}//sellerLogin()

function adminLogin(json) {
	var loginCheck = json.loginCheck;
	
	if(loginCheck == true) {
		alert('로그인 되었습니다.');
		location.href="/Jangdolbaeng2/admin/adminPage.action";		
	}
	else {
		alert('올바른 아이디와 비밀번호를 입력해주세요.');
	}
	
}//adminLogin()

function product() {
	window.open("/Jangdolbaeng2/product/main.action");
}//product()

</script>
</head>
<body>
<div class="container" style="width:712px; padding-top:180px; margin:0 auto;">
	<div class="row" style="margin-left: 40px">
		<!-- list navigation for tabs  -->
		<ul class="nav nav-tabs" style="border: none;">
             <li class="active"><a href="#seller" data-toggle="tab"><span class="glyphicon glyphicon-star" style="color: #62943d"></span> <span style="font-family: anew; color: #62943d"> 상인로그인</span></a></li>
             <li><a href="#admin" data-toggle="tab"><span class="glyphicon glyphicon-user" style="color: #62943d"></span> <span style="font-family: anew; color: #62943d"> 관리자로그인</span></a></li>
   		</ul>
   	</div>
   	<div class="clearfix visible-xs visible-lg"></div>
	<div class="thumbnail" style="padding-left: 50px; border-color: #62943d;">
			<div class="row">					
				<div class="col-lg-7" style="padding-top:50px">					
					<!-- text for each call out -->
					<div class="tab-content">             
			            <div class="tab-pane fade active in" id="seller"> 
			             	<table>
								<tr>
									<td><img alt="아이디" src="/Jangdolbaeng2/img/customer/fld_id.gif"></td>
									<td><input type="text" id="seller_id" name="seller_id" size="20"></td>
									<td rowspan="2" align="center">&nbsp;<img src="/Jangdolbaeng2/img/admin/btn.png" id="seller_login"></td>
								</tr>
								<tr>
									<td><img alt="비밀번호" src="/Jangdolbaeng2/img/customer/fld_pw.gif"></td>
									<td><input type="password" id="seller_password" name="password"></td>
									<td></td>
								</tr>
							</table>
			    		</div>
			            <div class="tab-pane fade" id="admin">  
			             	<table>
								<tr>
									<td><img alt="아이디" src="/Jangdolbaeng2/img/customer/fld_id.gif"></td>
									<td><input type="text" id="admin_id" name="seller_id" size="20"></td>
									<td rowspan="2" align="center">&nbsp;<img src="/Jangdolbaeng2/img/admin/btn.png" id="admin_login"></td>
								</tr>
								<tr>
									<td><img alt="비밀번호" src="/Jangdolbaeng2/img/customer/fld_pw.gif"></td>
									<td><input type="password" id="admin_password" name="password"></td>
									<td></td>
								</tr>
							</table>
			            </div> 
					</div>										
				</div>
			<div class="col-lg-5">
				<a href="javascript: product()"><img alt="로고" src="/Jangdolbaeng2/img/admin/logo4.jpg"></a>
			</div>			
		</div>		
	</div><!-- end of thumbnail -->
	
	<div class="row" style="padding: p5x 0px 0px 10px; margin-left: 10px">
		<p><small>*시스템 이용시 불편사항은 상인회에 문의주시면 신속히 답변드리겠습니다.</small><br>
		<span style="margin-left: 5px; color: #62943d"><b><small>상인회 전화번호: 02-124-4567</small></b></span>
	<p></p>
	</div>
	
</div><!-- end of container -->
</body>

</html>